const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');


const studentManagerRouter = express.Router();

// parse application/x-www-form-urlencoded
studentManagerRouter.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
studentManagerRouter.use(bodyParser.json())

//导入学生管理控制模块
const studentManagerControl = require(path.join(__dirname,"../control/studentManagerControl.js"));
//获取学生列表页面
studentManagerRouter.get('/list',(req,res)=>{
    studentManagerControl.getStudentListPage(req,res);
})
//获取新增学生页面
studentManagerRouter.get('/add',(req,res)=>{
    studentManagerControl.getAddStudentPage(req,res);
})
//新增学生逻辑处理
studentManagerRouter.post('/add',(req,res)=>{
    studentManagerControl.addStudent(req,res);
})
//获取修改学生页面
studentManagerRouter.get('/edit/:studentId',(req,res)=>{
    studentManagerControl.getEditStudentPage(req,res);
})
//修改学生信息逻辑处理
studentManagerRouter.post('/edit/:studentId',studentManagerControl.getUpdateStudentInfo)
//删除学生信息逻辑处理
studentManagerRouter.get('/delete/:studentId',studentManagerControl.DelteStudent)
module.exports = studentManagerRouter;